package com.example.springmvcdemo;

import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/headerReq")
@RestController
public class headerReq {
    //使用 HTTPServletRequest
    @RequestMapping("/getHeader1")
    public String getHeader1(HttpServletRequest request){
        String userAgent = request.getHeader("User-Agent");
        String referer = request.getHeader("Referer");//null
        System.out.println(userAgent+" "+referer);
        return "获取成功";
    }

}
